package com.edu.demo.service.impl;

import com.edu.demo.entity.Report;
import com.edu.demo.mapper.ReportMapper;
import com.edu.demo.service.IReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.edu.demo.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 报告表 服务实现类
 * </p>
 *
 * @author jixuewei
 * @since 2023-01-12
 */
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements IReportService {

    @Autowired
    private ReportMapper reportMapper;

    /**
     * 查询date这一周的报告
     *
     * @param date
     * @param projectId
     * @return
     */
    @Override
    public Report selectThisWeek(Date date, Integer projectId) {
       return reportMapper.selectReportByWeekOfDate(projectId,date);

    }

    /**
     * 查询该项目的并且是学生自己的周报告数
     *
     * @param projectId
     * @return
     */
    @Override
    public int countMine(int projectId) {
        return reportMapper.count(projectId, SecurityUtils.getStudent().getId());
    }
}
